All Questions
24 questions
0votes
1answer
268views
how to check for specific string in a file named abc.txt and write that missing string to another file (xyz.txt) using a shell script?
For example, generally I need to check for 5 strings. (Note : the strings are in file format .txt) file1.txt file2.txt file3.txt file4.txt file5.txt but there are 3 strings in abc.txt file1.txt ...
0votes
0answers
158views
filewatcher script in ksh script
I wanted to edit a already created filewatcher script with the given logic the source file path is stage path (stage/filewatcherwrap.ksh) there are 4 files in the below given format in stage path ...
0votes
3answers
1kviews
Concatenate files with same structure, keeping header only for 1st file
I want to merge 28 files with different names and the same data structure, using the script below: $ cp mohan.csv Consolidate.csv $ for fname in line do cat $fname | sed '1d' >> ...
0votes
3answers
43views
How to nullify multiple columns at specific positions?
Input- FN|LN|ADD|STATE|PIN|CONT|GRP|PCN|BIN|TOKEN72|TOKEN73|TOKEN74|TOKEN75|ndc|ncpdpd FN1|LN1|ADD1|STATE1|PIN1|CONT1|GRP1|PCN1|BIN1|TOKEN721|TOKEN731|TOKEN741|TOKEN751|ndc1|ncpdpd1 FN2|LN2|ADD2|...
1vote
1answer
124views
Unable to find regular file with default shell as bash but works when it's ksh
We have script file FileChecker.sh where it checks whether file exists or not FileChecker.sh content: #!/bin/ksh FILE=$1 FILE2=$2 if [[ "$FILE" == "" || "$FILE2" == "" ]] ; then echo "[ERROR] ...
1vote
2answers
570views
script with date work on Linux but not on AIX
I wrote a script to that works fine on Linux but fails on AIX 7.2. My script uses the command date with -d. The purpose of this script is to get the last day that is not a Saturday, Sunday or a ...
0votes
1answer
2kviews
Assigning a variable within a while loop in shell script
I am trying to assign a variable within a while loop and the script hangs during the read statement. while read -r port 60720 60721 60722 60723 60724 here is the code: qmgrs=$($MQ_INSTALL_PATH/...
1vote
1answer
764views
Why does =~ operator give a syntax error on Solaris while comparing with a regular expression
I used this following piece of code appcount_range="^[1-$APP_COUNT]$" until [[ $APP_OPTION =~ $appcount_range ]] do echo "INVALID CHOICE! Please enter a valid option:" ...
0votes
2answers
455views
IF-ELSE - Y|N response does not work as required
I am just finding it hard to achieve below using for-loop. Your suggestions/help will be really appreciated. Thanks If user responds in upper or lower case then it should accept and convert in ...
0votes
1answer
1kviews
bash script fails to run under ksh
I have below script which run successfully if i use #!/usr/bin/env bash. The same script is getting unexpected EOF while looking for matching " error while using #!/bin/ksh. Why is that? #!/usr/...
0votes
1answer
461views
cannot reload .profile from script
I am trying to reload .profile from the below script, but that doesn't work at all. #!/bin/ksh sed -i '/export rel=Rel1510_Linux/c\export rel=Rel1602_MX' ~/.profile source ~/.profile When I run this ...
1vote
1answer
227views
Catenation of two commands to a file and email output
#!/bin/ksh #HOSTS format: HOSTS="xxxx.xxx.xxx.xx-ACCOUNT" FILE=/home/angela/list.txt #list will be saved on list.txt date > $FILE echo >> $FILE for host in $HOSTS; do ip=$(echo $host|...
19votes
5answers
87kviews
telnet command with custom timeout duration
I'm trying to execute telnet command and getting the out put on shell script. But when the port not open or the ip not exist. The command take too much time to give the response. Will it be possible ...
-2votes
1answer
2kviews
Shell script curl limit the try time for page not found
I found following code to check web url. if curl --output /dev/null --silent --head --fail "$url"; then echo "URL exists: $url" else echo "URL does not exist: $url" fi Here if the page not exist ...
4votes
2answers
5kviews
Subtract floating numbers in shell script
I'm trying to do some calculation in shell script with CPU usage. Which return floating point number. But when I subtract this number I'm getting error. See the following code and error. Code #!/bin/...